package com.huawei.appmarket.support.emui.permission;

import android.annotation.TargetApi;
import android.os.Bundle;
import com.huawei.appmarket.framework.activity.SecureActivity;
import o.cdb;
import o.ceh;
import o.PermissionChecker;
import o.cjo;
import o.dky.j;
import o.NetWorkUtls;
import o.erx;
import o.erx.c;
import o.ery;
import o.eti;

public abstract class BasePermissionActivity<T extends cjo> extends SecureActivity<T> implements ceh {
    protected NetWorkUtls ˋॱ;
    boolean ॱˋ = false;

    protected abstract void ॱॱ();

    protected int ʿ() {
        return j.ᐨ;
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        if (((eti) cdb.ॱ(eti.class)).ˊ(this)) {
            finish();
            return;
        }
        ˎ(bundle);
        ʼ();
        erx ˎ = ery.ˎ("rootcheck.interrupter", this);
        if (ˎ == null || !ˎ.needInterruption()) {
            ʼॱ();
            return;
        }
        ˎ.setListener(new c(this) {
            final /* synthetic */ BasePermissionActivity ˋ;

            {
                this.ˋ = r1;
            }

            public void ॱ(boolean z) {
                if (z) {
                    this.ˋ.ʼॱ();
                } else {
                    this.ˋ.finish();
                }
            }
        });
        ˎ.doInterruption();
    }

    protected void ˎ(Bundle bundle) {
        if (bundle != null) {
            this.ॱˋ = bundle.getBoolean("permission_dialog_state");
        }
    }

    protected void ʼॱ() {
        erx ˎ = ery.ˎ("permission.interrupter", this);
        if (ˎ == null || ˎ.needInterruption()) {
            if (this.ॱˋ) {
                ᐝ();
                return;
            } else if (PermissionChecker.ˋ(this, 14)) {
                if (this.ˋॱ != null) {
                    this.ˋॱ.dismiss();
                    return;
                }
                return;
            }
        }
        ॱॱ();
    }

    public void onDestroy() {
        super.onDestroy();
        if (this.ˋॱ != null) {
            this.ˋॱ.dismiss();
        }
    }

    public void onSaveInstanceState(Bundle bundle) {
        if (bundle != null) {
            if (this.ˋॱ == null || !this.ˋॱ.isShowing()) {
                bundle.putBoolean("permission_dialog_state", false);
            } else {
                bundle.putBoolean("permission_dialog_state", true);
            }
            super.onSaveInstanceState(bundle);
        }
    }

    protected void ʼ() {
    }

    @TargetApi(23)
    public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        if (14 == i) {
            PermissionChecker.ˎ(this, i, strArr, iArr);
        }
    }

    public void ˏ(int i, int i2) {
        if (i2 == 0) {
            ॱॱ();
        } else {
            ᐝ();
        }
    }

    @TargetApi(24)
    private void ᐝ() {
        boolean shouldShowRequestPermissionRationale = shouldShowRequestPermissionRationale("android.permission.READ_PHONE_STATE");
        if (this.ˋॱ == null) {
            this.ˋॱ = new NetWorkUtls();
        }
        this.ˋॱ.showDial(this, shouldShowRequestPermissionRationale, ʿ(), 14);
    }
}
